﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.UI.Script
{
    public class AreaScriptObject: PartScriptObject
    {
        private WeakReference _area;
        public AreaScriptObject(AreaPart area)
            : base(area)
        {
            _area = new WeakReference(area);
        }

        public object getObject(string name)
        {
            AreaPart area = _area.Target as AreaPart;
            if (area == null)
            {
                return null;
            }
            UI.Part part = area.GetChildPart(name, true);
            if (part != null)
            {
                return part.GetScriptObj();
            }
            return null;
        }
    }
}